{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'IDE': {'IDLE': ['操作:70%', '意义:80%'],\n",
       "  'jupyter': ['操作：80%', '意义：90%'],\n",
       "  'pycharm': ['操作：90%', '意义：90%']},\n",
       " 'data_value': {'str': ['操作:80%', '意义:80%'],\n",
       "  'num': ['操作：80%', '意义：90%'],\n",
       "  'Booleans': ['操作：90%', '意义：90%']},\n",
       " 'data_structure': {'list': ['操作:70%', '意义:80%'],\n",
       "  'dict': ['操作：80%', '意义：80%'],\n",
       "  'set': ['操作：80%', '意义：90%'],\n",
       "  'tuple': ['操作：70%', '意义：80%']},\n",
       " '语句': {'总体': ['操作:70%', '意义:80%']},\n",
       " 'BIF': {'总体': ['操作:70%', '意义:70%']},\n",
       " '操作符': {'总体': ['操作:70%', '意义:80%']},\n",
       " '切片': {'总体': ['操作:70%', '意义:80%']},\n",
       " '函数': {'总体': ['操作:60%', '意义:70%']},\n",
       " 'PEP8': {'总体': ['操作:80%', '意义:90%']},\n",
       " 'docstring': {'总体': ['操作:80%', '意义:90%']}}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "python_base={\n",
    "    \n",
    "       \"IDE\": {  \n",
    "               \"IDLE\":[\"操作:70%\",\"意义:80%\"],\n",
    "               \"jupyter\":[\"操作：80%\",\"意义：90%\"],\n",
    "               \"pycharm\":[\"操作：90%\",\"意义：90%\"] \n",
    "                       },\n",
    "    \n",
    "        \"data_value\":{  \n",
    "               \"str\":[\"操作:80%\",\"意义:80%\"],\n",
    "               \"num\":[\"操作：80%\",\"意义：90%\"],\n",
    "               \"Booleans\":[\"操作：90%\",\"意义：90%\"] \n",
    "                       },\n",
    "        \n",
    "         \"data_structure\":{  \n",
    "               \"list\":[\"操作:70%\",\"意义:80%\"],\n",
    "               \"dict\":[\"操作：80%\",\"意义：80%\"],\n",
    "               \"set\":[\"操作：80%\",\"意义：90%\"],\n",
    "               \"tuple\":[\"操作：70%\",\"意义：80%\"] \n",
    "                       },\n",
    "    \n",
    "         \"语句\":{  \n",
    "               \"总体\": [\"操作:70%\",\"意义:80%\"],\n",
    "                       },\n",
    "    \n",
    "         \"BIF\":{  \n",
    "               \"总体\": [\"操作:70%\",\"意义:70%\"],\n",
    "                       },\n",
    "    \n",
    "         \"操作符\":{  \n",
    "               \"总体\": [\"操作:70%\",\"意义:80%\"],\n",
    "                       },\n",
    "    \n",
    "         \"切片\":{  \n",
    "               \"总体\": [\"操作:70%\",\"意义:80%\"],\n",
    "                       },\n",
    "    \n",
    "         \"函数\":{  \n",
    "               \"总体\": [\"操作:60%\",\"意义:70%\"],\n",
    "                       },\n",
    "\n",
    "         \"PEP8\":{  \n",
    "               \"总体\": [\"操作:80%\",\"意义:90%\"],\n",
    "                       },\n",
    "\n",
    "         \"docstring\":{  \n",
    "               \"总体\": [\"操作:80%\",\"意义:90%\"],\n",
    "                       },\n",
    "\n",
    "               }\n",
    "df = pd.DataFrame(python_base)\n",
    "df1 = df.T\n",
    "\n",
    "python_base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df1.replace(\"NaN\",\"1\")#前面是需要替换的值，后面是替换后的值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df.replace(\"NaN\",\"1\")#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# #翻转\n",
    "# df.reindex(index=df.index[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "IDLE      IDE               [操作:70%, 意义:80%]\n",
       "jupyter   IDE               [操作：80%, 意义：90%]\n",
       "pycharm   IDE               [操作：90%, 意义：90%]\n",
       "str       data_value        [操作:80%, 意义:80%]\n",
       "num       data_value        [操作：80%, 意义：90%]\n",
       "Booleans  data_value        [操作：90%, 意义：90%]\n",
       "list      data_structure    [操作:70%, 意义:80%]\n",
       "dict      data_structure    [操作：80%, 意义：80%]\n",
       "set       data_structure    [操作：80%, 意义：90%]\n",
       "tuple     data_structure    [操作：70%, 意义：80%]\n",
       "总体        语句                [操作:70%, 意义:80%]\n",
       "          BIF               [操作:70%, 意义:70%]\n",
       "          操作符               [操作:70%, 意义:80%]\n",
       "          切片                [操作:70%, 意义:80%]\n",
       "          函数                [操作:60%, 意义:70%]\n",
       "          PEP8              [操作:80%, 意义:90%]\n",
       "          docstring         [操作:80%, 意义:90%]\n",
       "dtype: object"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame.stack(df, level=-1, dropna=True)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
